<template>
	<view class="all">
		<view class="status_bar">
		            <!-- 这里是状态栏 -->
		        </view>
		<view class="fidexs">
			<view class="all_title">
				<view class="groups" @click="tos">
					<u-icon name="arrow-left" :bold="true" color="rgba(46, 46, 46, .5)" size="20"></u-icon>
					<view class="mod">分类列表</view>
				</view>
				<u-icon name="home" color="rgba(46, 46, 46, .5)" @click="mesg" size="28"></u-icon>
			</view>
		</view>
		<view class="top_nav">
			<view class="list_book" v-for="(item,index) in list"  @click="pop(item.sourceId)">
				<image :src="item.coverUrl">
				</image>
				<view class="list_book_right">
					<view class="list_book_title">
						{{item.title}}
					</view>
					<u--text :lines="2" line-height="20px" size="12" color="rgba(46,46,46,.5)" :text="item.intro">
					</u--text>
					<view class="list_book_i">
						<text class="names">{{item.authorName}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				list: [],
				id:0,
				num: 1,
				categoryId:''
			}
		},
		filters:{
			words(value){
				return Math.floor(value / 10000) + "万字"  
			}
			
		},
		methods: {
			tos() {
				uni.navigateBack({
					delta:1
				})
			},
			mesg() {
				uni.navigateBack({
					url: '/pages/message/message'
				})
			},
			pop(id){
				console.log(id,999454546)
				uni.navigateTo({
					url:'/pages/books/books?sourceId='+id
				})
			},
		},
		onLoad(Option){
			console.log(Option.categoryId,100000)
				this.categoryId=Option.categoryId
				uni.$http.get('https://m.taoyuewenhua.com/ajax/book_mall/categories/'+Option.categoryId+'?category_books='+Option.categoryId+'&page=0&pageSize=10'
						).then(res => {
						this.list = res.data.data.bookList
					}).catch(err => {
					console.log(err)
				})
		},
		onReachBottom() {
			uni.$http.get('https://m.taoyuewenhua.com/ajax/book_mall/categories/'+this.categoryId+'?category_books='+this.categoryId+'&page='+this.num+'&pageSize=10'
					).then(res => {
					this.num++
					this.list = [...this.list, ...res.data.data.bookList]
				}).catch(err => {
				console.log(err)
			})
		},
	}
</script>

<style lang="scss">
	.status_bar {
	       height: var(--status-bar-height);
	       width: 100%;
	   }
	.fidexs {
		    position: fixed;
		    top: var(--status-bar-height);
		    right: 0;
		    left: 0;
		    background: #fff;
		    z-index: 11;
			border-bottom: 2rpx solid #eee;
	}
	.all_title {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
		height: 80rpx;
		border-bottom: 2rpx solid #ededed;
		background-color: #fff;
	
		.groups {
			display: flex;
			align-items: flex-end;
	
			.mod {
				margin-left: 20rpx;
			}
		}
	}
	.top_nav {
		padding: 80rpx 30rpx 0;
		.list_book {
			display: flex;
			padding: 0rpx 0rpx 30rpx;
			border-bottom: 2rpx solid #ededed;
			margin-top: 30rpx;
			image {
				width: 150rpx;
				height: 200rpx;
				padding-right: 20rpx;
			}
	
			.list_book_right {
				width: 75%;
				display: flex;
				flex-direction: column;
	
				.list_book_title {
					color: 2e2e2e;
					font-size: 26rpx;
					font-weight: bolder;
					margin-bottom: 22rpx;
				}
	
				.list_book_i {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 22rpx;
	
					.names {
						font-size: 24rpx;
						color: rgba(46, 46, 46, .5);
					}
				}
			}
		}
	
	}
	.mo ::v-deep .u-tabs__wrapper__nav {
		    display: flex;
		    flex-direction: row;
		    flex: 1;
		    position: relative;
		    justify-content: space-around;
	}
	 .status_bar {
	        height: var(--status-bar-height);
	        width: 100%;
	    }
</style>
